package com.chendx.article.controller.v1;

import com.chendx.api.article.ApArticleControllerApi;
import com.chendx.article.service.ApArticleService;
import com.chendx.article.service.ApCollectionService;
import com.chendx.model.article.dtos.CollectionBehaviorDto;
import com.chendx.model.article.pojos.ApArticle;
import com.chendx.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by chendx on 2022/3/4.
 */
@RestController
@RequestMapping("/api/v1")
public class ApArticleController implements ApArticleControllerApi {
    @Autowired
    private ApArticleService articleService;
    @Autowired
    private ApCollectionService apCollectionService;
    @PostMapping("/article/save")
    @Override
    public ApArticle saveArticle(@RequestBody ApArticle apArticle) {
        articleService.save(apArticle);
        return apArticle;
    }

    @PostMapping("/collection_behavior")
    @Override
    public ResponseResult collection(@RequestBody CollectionBehaviorDto dto) {
        return apCollectionService.collect(dto);
    }

}
